import {
  INCREMENTCOUNT,
  DECREMENTCOUNT
} from "../constant/countConst"

const init = {
  count: 0
}

export default function countReducer(prevStata = init, action) {
  const { type, data } = action

  switch (type) {
    case INCREMENTCOUNT:
      return {
        ...init, count: prevStata.count + data
      };
    case DECREMENTCOUNT:
      return {
        ...init, count: prevStata.count - data
      }
  }

  return prevStata
}
